using Cysharp.Threading.Tasks;
using System;
using UnityEngine;

public interface IAgvCommand
{
    int ActionCode { get; set; }
    string PointName { get; set; }
    string ActionStr { get; set; }
    float Direction { get; set; }
    Action<IAgvCommand, string> OnExecuteAction { get; set; }
    bool IsAsyncEnd { get; set; }
    bool IsExecuting { get; set; }
    void Execute();
}

public class AgvIdleCommand : IAgvCommand
{
    public int ActionCode { get; set; }
    private string height;
    public AgvIdleCommand(string pointName)
    {
        this.height = "0.475";
        PointName = pointName;
    }
    public string ActionStr { get; set; } = "Idle";
    public float Direction { get; set; }
    public Action<IAgvCommand, string> OnExecuteAction { get; set; }
    public bool IsAsyncEnd { get; set; }
    public bool IsExecuting { get; set; }
    public string PointName { get; set; }

    public void Execute()
    {
        IsExecuting = true;
        OnExecuteAction.Invoke(this, height);
    }
}
public class AgvMoveCommand : IAgvCommand
{
    public int ActionCode { get; set; }
    public string ActionStr { get; set; }
    public Transform Transform { get; private set; }
    public Vector3 Target { get; private set; }
    public AgvMoveCommand(Transform transform, Vector3 target, float direction)
    {
        this.Target = target;
        this.Transform = transform;
        Direction = direction;
    }
    public float Direction { get; set; }
    public string PointName { get; set; }
    public Action<IAgvCommand, string> OnExecuteAction { get; set; }
    public bool IsAsyncEnd { get; set; }
    public bool IsExecuting { get; set; }

    public void Execute()
    {
        IsExecuting = true;
        OnExecuteAction.Invoke(this, "");
        IsAsyncEnd = true;
    }
}
public class AgvPickCommand : IAgvCommand
{
    public int ActionCode { get; set; }
    private string height;
    public AgvPickCommand(string height, string direction, string pointName)
    {
        Direction = direction == "1" ? 1 : -1;
        this.height = height;
        PointName = pointName;
    }
    public string ActionStr { get; set; }
    public float Direction { get; set; }
    public string PointName { get; set; }
    public Action<IAgvCommand, string> OnExecuteAction { get; set; }
    public bool IsAsyncEnd { get; set; }
    public bool IsExecuting { get; set; }
    public void Execute()
    {
        IsExecuting = true;
        OnExecuteAction.Invoke(this, height);
        //IsAsyncEnd = true;
        //throw new System.NotImplementedException();
    }
}
public class AgvPutCommand : IAgvCommand
{
    public int ActionCode { get; set; }
    private string height;
    public AgvPutCommand(string height, string direction, string pointName)
    {
        Direction = direction == "1" ? 1 : -1;
        this.height = height;
        PointName = pointName;
    }
    public string ActionStr { get; set; }
    public float Direction { get; set; }
    public string PointName { get; set; }
    public Action<IAgvCommand, string> OnExecuteAction { get; set; }
    public bool IsAsyncEnd { get; set; }
    public bool IsExecuting { get; set; }
    public void Execute()
    {
        IsExecuting = true;
        OnExecuteAction.Invoke(this, height);
        //IsAsyncEnd = true;
        //throw new System.NotImplementedException();
    }
}

public class AgvLiftCommand : IAgvCommand
{
    public int ActionCode { get; set; }
    private string height;
    public AgvLiftCommand(string height, string pointName)
    {
        this.height = height;
        PointName = pointName;
    }
    public string ActionStr { get; set; }
    public float Direction { get; set; }
    public string PointName { get; set; }
    public Action<IAgvCommand, string> OnExecuteAction { get; set; }
    public bool IsAsyncEnd { get; set; }
    public bool IsExecuting { get; set; }
    public void Execute()
    {
        IsExecuting = true;
        OnExecuteAction.Invoke(this, height);
    }
}